<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>添加课程</title>


<link href="${base}/resources/admin/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        .text-line {
            line-height: 20px;
        }
    </style>

</head>
<body>
	<div class="path">
		<a href="${base}/asl-admin/common/index.htm">${message("admin.path.index")}</a> &raquo; 添加课程
	</div>
	<form id="inputForm" action="save.htm" method="post">
		<table class="input">
            <tr>
                <th>
                    <span class="requiredField">*</span>老师:
                </th>
                <td>
                    <select name="memberId" data-am-selected="{searchBox: 1}">
                    [#list members as m ]
                        [#if m.type="teacher"]
                            <option value="${m.id}" >${m.username}[#if m.name]（${m.name}）[/#if]</option>
                        [/#if]
                    [/#list]
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>分类:
                </th>
                <td>
                    <select name="categoryId">
                    [#if categories??]
                        [#list categories as c ]
                            <option value="${c.id}" >${c.name}</option>
                        [/#list]
                    [/#if]
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    上传封面:
                </th>
                <td>
					<span class="fieldSet">
						<input type="text" name="imageURL" class="text" maxlength="200" title="${message("admin.imageTitle")}" placeholder="请选择图片上传"/>
						<input type="button" id="browserButton" class="button" value="${message("admin.browser.select")}" />
					</span>
                </td>
            </tr>
			<tr>
				<th>
					<span class="requiredField">*</span>标题:
				</th>
				<td>
					<input type="text" name="title" class="text" maxlength="200" placeholder="请输入标题"/>
				</td>
			</tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>开播日期:
                </th>
                <td>
                    <input type="text" id="birth" name="pattern" class="text Wdate" onfocus="WdatePicker({minDate:'%y-%M-%d', dateFmt: 'yyyy-MM-dd HH:mm'});" placeholder="请选择日期"/>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>简介:
                </th>
                <td>
                    <textarea name="introduction" class="text text-line" style="width: 400px;height: 200px" placeholder="请输入简介"></textarea>
                </td>
            </tr>
            <tr>
                <th>
                    是否置顶:
                </th>
                <td>
                    <label><input type="radio" name="isTop" value="true" />是</label>
                    <label><input type="radio" name="isTop" value="false" checked/>否</label>
                </td>
            </tr>
            <tr>
                <th>
					是否收费:
                </th>
                <td>
                    <label>
                        <input type="checkbox" id="charge" name="charge" value="true" checked="checked" />是
                    </label>
                </td>
            </tr>
            <tr id="chagrge-encrypt">
                <th>
				    是否加密:
                </th>
                <td>
                    <label>
                        <input type="checkbox" id="encrypt" name="encrypt" value="true" checked="checked" />是
                    </label>
                </td>
            </tr>
            <tr id="password">
                <th>
                    <span class="requiredField">*</span>密码:
                </th>
                <td>
                    <input type="text" name="password" class="text" placeholder="请输入密码"/>
                </td>
            </tr>
            <tr id="price">
                <th>
                    <span class="requiredField">*</span>价格:
                </th>
                <td>
                    <input type="price" name="price" class="text" placeholder="请输入价格,保留两位小数"/>
                </td>
            </tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="${message("admin.common.submit")}" />
					<input type="button" class="button" value="${message("admin.common.back")}" onclick="location.href='list.htm'" />
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.tools.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/amazeui.min.js"></script>
<script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<script type="text/javascript" src="${base}/resources/admin/datePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $().ready(function() {

        var $inputForm = $("#inputForm");
        var $browserButton = $("#browserButton");
        var $charge = $("#charge");
        var $price = $("#price");
        var $encrypt = $("#encrypt");
        var $password = $("#password");
        var $chagrge_encrypt = $("#chagrge-encrypt");

    [@flash_message /]

        $browserButton.browser();

        $charge.on("click", function () {
            if($(this).attr("checked") == null){
                $price.hide();
                $price.empty();
                $chagrge_encrypt.hide();
                $password.hide();
            } else {
                $price.show();
                $chagrge_encrypt.show();
                var shtml = '<th><span class="requiredField">*</span>价格:</th><td><input type="price" name="price" class="text" placeholder="请输入价格,保留两位小数"/></td>';
                $price.html(shtml);
                if ($encrypt.attr("checked") != null) {
                    $password.empty();
                    $password.show();
                    var shtml = '<th><span class="requiredField">*</span>密码:</th><td><input type="text" name="password" class="text" placeholder="请输入密码"/></td>';
                    $password.html(shtml);
                }
            }
        })

        $encrypt.on("click", function () {
            if($(this).attr("checked") == null){
                $password.hide()
                $password.empty();
            } else {
                $password.show();
                var shtml = '<th><span class="requiredField">*</span>密码:</th><td><input type="text" name="password" class="text" placeholder="请输入密码"/></td>';
                $password.html(shtml);
            }
        })

        // 表单验证
        $inputForm.validate({
            rules: {
                title: "required",
                pattern: "required",
                introduction : "required",
                password: {
                    pattern: /^[^\s&\"<>]+$/,
                    minlength: 6,
                    maxlength: 20,
                    required: true
                },
                price: {
                    min: 0.01,
                    pattern:/^(([0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
                    required:true
                },
                memberId: "required",
                categoryId: "required"
            },
        });

    });

</script>
</html>
